package cn.touna.jss.util;

import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class URLConnection {

    public static HttpURLConnection getConnection(String url) {
        HttpURLConnection connection = null;
        try {
            URL postUrl = new URL(url);
            // 打开连接
            connection = (HttpURLConnection) postUrl
                    .openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.setUseCaches(false);
            connection.setInstanceFollowRedirects(true);
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Charset", "utf-8");
            connection.setRequestProperty("Accept-Charset", "utf-8");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return connection;
    }

    @Test
    public void urlComponentsTest() {
        JSONObject param = new JSONObject();
        param.put("hello", "world");


    }
}
